package com.icez.indicator_view

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper

class Utils {
    companion object {
        val instance: Utils by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
             Utils()
        }
    }

    /**
     * 通过context获取Activity
     * @sample
     * @author Icez
     */
    public fun getActivity(mContext: Context?): Activity?{
        var context = mContext
        while (context is ContextWrapper){
            if(context is Activity){
                return context
            }else{
                context = (context as ContextWrapper).baseContext
            }
        }
        return null
    }
}